﻿using System;
using System.ComponentModel;
using System.Linq.Expressions;

namespace WPFToolBarExample.ViewModel
{
  public class BaseViewModel : INotifyPropertyChanged
  {
    #region INotifyPropertyChanded event Implementation

    public event PropertyChangedEventHandler PropertyChanged;

    public void OnPropertyChanged<TProperty>(Expression<Func<TProperty>> propertyExpression)
    {
      PropertyChangedEventHandler handler = PropertyChanged;

      if (null == handler)
        return;

      if (null != propertyExpression)
      {
        var e = new PropertyChangedEventArgs(((MemberExpression)propertyExpression.Body).Member.Name);
        handler(this, e);
      }
    }

    public void OnPropertyChanged(string propertyName)
    {
      PropertyChangedEventHandler handler = PropertyChanged;

      if (null != PropertyChanged)
        handler(this, new PropertyChangedEventArgs(propertyName));
    }
    #endregion

    public virtual void Save()
    {

    }

    public virtual void Update()
    {

    }
    public virtual void Delete()
    {

    }
  }
}
